package com.kkwrite.regimen.provider.controller.point;

import com.kkwrite.regimen.common.constant.Constant;
import com.kkwrite.regimen.common.entity.dto.OutDTO;
import com.kkwrite.regimen.common.entity.dto.point.PageablePointRecordOutDTO;
import com.kkwrite.regimen.provider.service.point.PointService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by lisha on 2018/7/21 17:56.
 *
 * @author lisha
 */
@RestController
@RequestMapping(value = "/point")
public class PointController {

    @Resource(name = "pointService")
    private PointService pointService;

    @GetMapping(value = "/recordList")
    public OutDTO<PageablePointRecordOutDTO> queryRecordList(Integer page, Integer size,
                                                             Integer userId, Integer sortType) {
        return pointService.listRecords(page, size, userId, sortType);
    }

	@GetMapping(value = "/queryPointTotal")
	public OutDTO queryPointTotal(Integer userId) {
		try {
			return OutDTO.of(Constant.BOOLEAN_STRING_TRUE, "OK", "OK", pointService.queryPointTotal(userId));
		} catch (Exception e) {
			return new OutDTO<>(Constant.BOOLEAN_STRING_FALSE, e.getMessage());
		}
	}

}
